<template>
  <div class="App">
    <!-- 占位 -->
    <transition :name="SkipSwitchName">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </transition>
    <AppImg></AppImg>
  </div>
</template>

<script>
import AppImg from '@/components/App/AppImg.vue'
export default {
  name: 'App',
  data() {
    return {
      SkipSwitchName: ''
    }
  },
  components: {
    AppImg
  },
  watch: {
    $route(to, from) {
      if (to.meta.tx > from.meta.tx) {
        this.SkipSwitchName = 'Skright'
      } else {
        this.SkipSwitchName = 'Skleft'
      }
    }
  }
}
</script>

<style lang="less" scoped>
.App {
  width: 100%;
  height: 100%;
}
.Skright-enter-active,
.Skright-leave-active,
.Skleft-enter-active,
.Sklef-leave-active {
  transition: all 600ms;
}
//先给 所要用的上下层级跳转写一个过渡时间
//然后你就可以发挥自己的想象力来写自己动画了 下面是一个例子
.Skright-enter {
  transform: translate3d(-100%, 0, 0);
}
.Skright-leave-to {
  transform: translate3d(100%, 0, 0);
}
.Skleft-enter {
  transform: translate3d(100%, 0, 0);
}
.Skleft-leave-to {
  transform: translate3d(-100%, 0, 0);
}
</style>
